package cn.zm.trip.web.controller;

import cn.zm.trip.web.dao.HotelDao;
import cn.zm.trip.web.dao.TrafficDao;
import cn.zm.trip.web.dao.ViewPointDao;
import cn.zm.trip.web.domain.Hotel;
import cn.zm.trip.web.domain.HotelExample;
import cn.zm.trip.web.domain.ViewPoint;
import cn.zm.trip.web.domain.ViewPointExample;
import cn.zm.trip.web.service.HotelService;
import cn.zm.trip.web.service.ViewPointService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping(value = "cust")
public class CustController {
	@Autowired
	TrafficDao trafficDao;
	@Autowired
	ViewPointDao viewPointDao;
	@Autowired
	ViewPointService viewPointService;
	@Autowired
	HotelDao hotelDao;
	@Autowired
	HotelService hotelService;

	/**
	 * 跳转定制
	 */
	@RequestMapping(value = "index", method = RequestMethod.GET)
	public String index() {
		return "proscenium/cust/index";
	}

	/**
	 * 定制返回景
	 */
	@ResponseBody
	@RequestMapping(value = "viewPoint", method = RequestMethod.GET)
	public List<ViewPoint> viewPoint(String tpLocation) {
		return viewPointDao.listViewPointByQuery(tpLocation,0,null,"tp_vid");
	}

	/**
	 * 定制返回酒店
	 */
	@ResponseBody
	@RequestMapping(value = "hotel", method = RequestMethod.GET)
	public List<Hotel> hotel(String local) {
		LambdaQueryWrapper<Hotel> queryWrapper = new LambdaQueryWrapper<>();
		queryWrapper.eq(Hotel::getLocal,local);
		return hotelService.list(queryWrapper);
	}
}
